C++ Program to Find Maximum value possible by rotating digits of a given number
Given a positive integer N, the task is to find the maximum value among all the rotations of the digits of the integer N....
read more
C++ Program to Move all zeroes to end of array | Set-2 (Using single traversal)
Given an array of n numbers. The problem is to move all the 0’s to the end of the array while maintaining the order of the other elements. Only single traversal of the array is required.Examples:...
read more
Minimum length of Run Length Encoding possible by removing at most K characters from a given string
Given a string S of length N, consisting of lowercase English alphabets only, the task is to find the minimum possible length of run-length-encoding that can be generated by removing at most K characters from the string S....
read more
Merge two unsorted linked lists to get a sorted list
Given two unsorted Linked List, the task is to merge them to get a sorted singly linked list.Examples:...
read more
C++ Program to Find all rectangles filled with 0
We have one 2D array, filled with zeros and ones. We have to find the starting point and ending point of all rectangles filled with 0. It is given that rectangles are separated and do not touch each other however they can touch the boundary of the array.A rectangle might contain only one element....
read more
Descartes’ Circle Theorem with implementation
In geometry, Descartes’ theorem states that for every four mutually tangent circles, the radii of the circles satisfy a certain quadratic equation. One can construct a fourth circle tangent to three given, mutually tangent circles. Descartes’ Circle Theorem helps us to find the radius of a circle when there are 4 circles with positive integer radius r1, r2, r3 and r4 as shown in the figure below. It finds the radius r4 of the circle formed by three circles of radius r1, r2, r3 as shown in the image below. (Note that the circles in the picture below are tangent to each other.)...
read more
Maximum of XOR of first and second maximum of all subarrays
Given an array arr[] of distinct elements, the task is to find the maximum of XOR value of the first and second maximum elements of every possible subarray.Note: Length of the Array is greater than 1. Examples:...
read more
How to Copy a List in C++ STL?
In C++, a list is a sequence container provided by the STL library that represents a doubly linked list and allows us to store data in non-contiguous memory locations efficiently. In this article, we will learn how to copy one list to another in C++....
read more
How to Release Memory in C++?
In C++, releasing memory means deallocating the memory that was previously allocated by the user. It is very important to avoid memory leaks. Other programming languages like Java support automatic garbage collection to release the dynamically allocated memory, but in C++ we have to release the allocated memory manually. In this article, we will learn how to release memory in C++....
read more
How to Implement a Copy Constructor for Deep Copying?
In C++, the copy constructor enables us to initialize an object using another object of the same class. In this article, we will learn, how to implement a copy constructor for deep copying....
read more
How to Declare a Vector in C++?
In C++, the vector is a dynamic array that can resize itself automatically to accommodate new elements. In this article, we will learn how to declare a vector in C++....
read more
How to Find the Cumulative Sum of Array in C++?
In C++, the cumulative sum, also known as the prefix sum of an array is the sum of all elements of the array at the current index including the sum of the previous elements. In this article, we will learn how to find the prefix sum of elements in an array in C++....
read more